package com.ruan.mycloudread.ui.gank;


import android.os.Bundle;
import android.support.annotation.Nullable;
import android.support.design.widget.TabLayout;
import android.support.v4.app.Fragment;

import com.ruan.mycloudread.R;
import com.ruan.mycloudread.base.BaseFragment;
import com.ruan.mycloudread.databinding.FragmentGankBinding;
import com.ruan.mycloudread.ui.gank.child.EverydayFragment;
import com.ruan.mycloudread.view.webview.MyFragmentPagerAdapter;

import java.util.ArrayList;


public class GankFragment extends BaseFragment<FragmentGankBinding> {
    private ArrayList<String> mTitleList = new ArrayList<>(4);
    private ArrayList<Fragment> mFragments = new ArrayList<>(4);


    @Override
    public int setContent() {
        return R.layout.fragment_gank;
    }

    @Override
    public void onActivityCreated(@Nullable Bundle savedInstanceState) {
        super.onActivityCreated(savedInstanceState);
        showLoading();
        initFragmentList();
        MyFragmentPagerAdapter myAdapter = new MyFragmentPagerAdapter(getChildFragmentManager(), mFragments, mTitleList);
        bindingView.vpGank.setAdapter(myAdapter);
        // 左右预加载页面的个数
        bindingView.vpGank.setOffscreenPageLimit(3);
        myAdapter.notifyDataSetChanged();
        bindingView.tabGank.setTabMode(TabLayout.MODE_FIXED);
        bindingView.tabGank.setupWithViewPager(bindingView.vpGank);
        showContentView();
    }

    private void initFragmentList() {
        mTitleList.add("每日推荐");
        mTitleList.add("福利");
        mTitleList.add("干货订制");
    //    mTitleList.add("大安卓");
        mFragments.add(new EverydayFragment());
        mFragments.add(new EverydayFragment());
        mFragments.add(new EverydayFragment());
       // mFragments.add(EverydayFragment.newInstance("Android"));
//        mFragments.add(AndroidFragment.newInstance("iOS"));
    }



}
